<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../Vue.js/vue.js"></script>
</head>
<body>
    <div class="root">
        <h3>今天天气{{info}}</h3>
        <button @click = "click_change">点击我改变天气</button>
        <br/>
        <h3>{{number.a}}</h3>
        <button @click = "number.a++">点击增大a</button>
        <h3>{{number.b}}</h3>
        <button @click = "number.b++">点击增大b</button>
    </div>
</body>
<script>
    const vm = new Vue({
        el: ".root",
        data:{
            hot: true,
            number: {
                a: 1,
                b: 1
            }
        },
        methods: {
            click_change(){
                this.hot = !this.hot;
            }
        },
        computed:{
            info(){
                return this.hot?"热死了":"不热";
            }
        },
        watch:{
            hot:{
                immediate: true,    //网页一打开就运行
                handler(newValue, oldvalue){
                    console.log("hot被修改了", newValue, oldvalue)
                }
            },
            number:{
                deep: true,
                handler(){
                    console.log("number被改变了")
                }
            }
        }
    })
</script>
</html>